let axios

const requests = {
    user: {
        login: data => axios.post('user/login',data),
        register: data => axios.post('user/register', data),
        password: data => axios.post('user/password', data),
        checkLogin: () => axios.get('user/login_status'),
        meta: () => axios.get('user/meta')
    },
    message: {
        listByMine: data => axios.post('message/list/mine', data),
        listByReceive: data => axios.post('message/list/receive', data),
        listByPick: data => axios.post('message/list/pick', data),
        listByTopic: data => axios.post('message/list/topic', data),
        new: data => axios.post('message/new', data),
        pick: () => axios.get('message/pick'),
        discard: data => axios.post('message/discard', data),
        reply: data => axios.post('message/reply', data),
        detail: id => axios.get('message/' + id)
    },
    topic: {
        detail: id => axios.get('topic/' + id),
        new: data => axios.post('topic/new', data),
        list: data => axios.post('topic/list', data),
        listMine: data => axios.post('topic/list/me', data),
        close: data => axios.post('topic/close', data)
    },
    profile: {
        getMe: () => axios.get('profile'),
        getById: id => axios.get('profile/' + id),
        update: data => axios.post('profile', data),
        updateConsultPrice: data => axios.post('profile/consult_price', data)
    },
    wallet: {
        getMe: () => axios.get('wallet'),
        recharge: data => axios.post('wallet/recharge', data),
        settle: data => axios.post('wallet/settle', data),
        settleLog: data => axios.post('wallet/settle/log', data)
    }
}

export function useRequests() {
    return requests
}

export default {
    install: (app, axiosInstance) => {
        axios = axiosInstance
        app.config.globalProperties.requests = requests
    }
}
